package com.example.adminframework.constant;

/**
 * @Date 2020.12.02
 * @Description 公共常量配置
 */
public class CommonConstant {
    //邮箱验证
    public static final String EMAIL_VERIFY = "(^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$)|(^$)";
    public static final String EMAIL_ERROR_MESSAGE = "请输入正确邮箱格式";

    //手机号验证
    public static final String PHONE_VERIFY = "(^(13[0-9]|14[5|7]|15[0|1|2|3|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\\d{8}$)|(^$)";
    public static final String PHONE_ERROR_MESSAGE = "请输入正确手机号";

    //ipv4验证
    public static final String IPV4_VERIFY = "^(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)(\\.(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)){3}$";
    public static final String IPV4_ERROR_MESSAGE = "请输入正确IPV4";

    //ipv6验证
    public static final String IPV6_VERIFY = "^s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:)))(%.+)?s*$";
    public static final String IPV6_ERROR_MESSAGE = "请输入正确IPV6";

    //子网掩码验证
    public static final String SUBNET_MASK_VERIFY = "^(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])(\\.(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])){3}$";
    public static final String SUBNET_MASK_ERROR_MESSAGE = "请输入正确子网掩码";

    //端口验证
    public static final String PORT_VERIFY = "^(/^([0-9]|[1-9]\\d|[1-9]\\d{2}|[1-9]\\d{3}|[1-5]\\d{4}|6[0-4]\\d{3}|65[0-4]\\d{2}|655[0-2]\\d|6553[0-5])$/.test(\"65535\") ";
    public static final String PORT_ERROR_MESSAGE = "请输入正确端口";

    //账号名称验证
    public static final String USERNAME_VERIFY = "^[a-zA-Z][a-zA-Z0-9_-]{3,63}$";
    public static final String USERNAME_ERROR_MESSAGE = "用户名格式有误(4到64位,字母，数字，下划线，减号,开头必须是字母)";

    //密码验证
    public static final String PASSWORD_VERIFY = "^[\\s\\S]{6,32}$";
    public static final String PASSWORD_ERROR_MESSAGE = "密码格式有误(6到32位)";

    //姓名验证
    public static final String NAME_VERIFY = "(^[\\u4E00-\\u9FA5A-Za-z0-9]{2,20}$)|(^$)";
    public static final String NAME_ERROR_MESSAGE = "名称只能是2-20位的中英文";

    //内容长度
    public static final String CONTENT_VERIFY = "(^[\\u4E00-\\u9FA5A-Za-z0-9]{5,1000}$)|(^$)";
    public static final String CONTENT_ERROR_MESSAGE = "内容只能是5-1000位的中英文";

    //权限module验证
    public static final String MODULE_VERIFY = "^[a-zA-Z][a-zA-Z0-9_-]{3,32}$";
    public static final String MODULE_ERROR_MESSAGE = "权限限制4-32英文字母数字下划线,并且只能以英文字母开头";

    //验证账户名唯一性
    public static final String USERNAME_ATTRIBUTE = "username";
    public static final String USERNAME_RULE = "only";
    public static final String USERNAME_ONLY_MESSAGE = "用户名已存在";

    //修改密码时验证原密码是否正确
    public static final String PASSWORD_ATTRIBUTE = "password";
    public static final String PASSWORD_RULE = "password";
    public static final String OLD_PASSWORD_MESSAGE = "原始密码错误";

    //验证模块名唯一性
    public static final String NAME_ATTRIBUTE = "name";
    public static final String TITLE_ATTRIBUTE = "name";
    public static final String MENU_PATH = "path";
    public static final String NAME_RULE = "only";
    public static final String DEPARTMENT_NAME_ONLY_MESSAGE = "部门名称已存在";
    public static final String ROLE_NAME_ONLY_MESSAGE = "角色名称已存在";
    public static final String MENU_NAME_ONLY_MESSAGE = "菜单名称已存在";
    public static final String DATASOURCE_API_NAME_ONLY_MESSAGE = "RESTFUL_API名称已存在";
    public static final String TASK_SCHEDULE_NAME_ONLY_MESSAGE = "RESTFUL_API名称已存在";
    public static final String MEBU_PATH_ONLY_ONE = "菜单地址已存在";
    public static final String INCIDENT_COMPRESS_NAME_ONLY_MESSAGE = "告警压缩名称已存在";
    public static final String INCIDENT_FILTER_NAME_ONLY_MESSAGE = "告警过滤名称已存在";
    public static final String ASSET_TYPE_NAME_ONLY_MESSAGE = "资产类型名称已存在";
    public static final String TITLE_ONLY_MESSAGE = "标题名称已存在";
    public static final String LABEL_NAME_ONLY_MESSAGE = "标签名称已存在";
    public static final String NAME_REPEAT_MESSAGE = "参数内名称重复";
    public static final String SEARCH_NAME_ONLY_MESSAGE = "搜索条件名称已存在";
    public static final String COLUMN_NAME_ONLY_MESSAGE = "字段显示的名称已存在";

    // 验证标识唯一性
    public static final String CODE_ATTRIBUTE = "code";
    public static final String ASSET_TYPE_CODE_ONLY_MESSAGE = "资产类型标识已存在";

    // 验证设备id唯一性
    public static final String ASS_NAME_ATTRIBUTE = "assName";
    public static final String ASS_SID_ONLY_MESSAGE = "装备已存在";

    // 验证密码加密
    public static final String USER_PASSWORD_ATTRIBUTE = "userPwd";
    public static final String  USER_PASSWORD_MESSAGE = "加/解密失败";

    // 验证父级
    public static final String PARENT_ID_ATTRIBUTE = "parentId";
    public static final String PARENT_RULE_NOT_SELF_OR_LOWER = "not_self_or_lower";
    public static final String PARENT_NOT_SELF_OR_LOWER = "上级不允许是自身及其下级";

    //验证权限唯一性
    public static final String PERMISSION_UNIQUE = "module";
    public static final String PERMISSION_ERROR_UNIQUE = "权限标识不能重复";

    //菜单路径验证
    public static final String MENU_PATH_VERIFY_COPY = "^[a-zA-Z][a-zA-Z0-9_-]{3,63}$";
    public static final String MENU_PATH_VERIFY = "^([hH][tT]{2}[pP]:/*|[hH][tT]{2}[pP][sS]:/*|[fF][tT][pP]:/*|[a-zA-Z][a-zA-Z0-9_-]{0,150})(([A-Za-z0-9-~]+).)+([A-Za-z0-9-~\\/])+(\\?{0,1}(([A-Za-z0-9-~]+\\={0,1})([A-Za-z0-9-~]*)\\&{0,1})*)$";
    public static final String MENU_PATH_ERROR_MESSAGE = "菜单地址格式有误(4到64位,字母，数字，下划线，减号,开头必须是字母)";

    //第三方api的url验证
    public static final String URL_VERIFY = "^((https|http|ftp)://)?"//(https或http或ftp):// 可有可无
            + "(([\\w_!~*\"()\\.&=+$%-]+: )?[\\w_!~*\"()\\.&=+$%-]+@)?" //ftp的user@  可有可无
            + "(([0-9]{1,3}\\.){3}[0-9]{1,3}" // IP形式的URL- 3位数字.3位数字.3位数字.3位数字
            + "|" // 允许IP和DOMAIN（域名）
            + "(localhost)|"	//匹配localhost
            + "([\\w_!~*\"()-]+\\.)*" // 域名- 至少一个[英文或数字_!~*\"()-]加上.
            + "\\w+\\." // 一级域名 -英文或数字  加上.
            + "[a-zA-Z]{1,6})" // 顶级域名- 1-6位英文
            + "(:[0-9]{1,5})?" // 端口- :80 ,1-5位数字
            + "((/?)|" // url无参数结尾 - 斜杆或这没有
            + "(/[\\w_!~*\"()\\.;?:@&=+$,%#-]+)+/?)$";

    //第三方api的url验证
    public static final String URL_ERROR_MESSAGE = "请输入正确的url地址";
}
